﻿using System;
using BusinessObjects.Entities.Base;
using FluentNHibernate.Mapping;

namespace BusinessObjects.Mappings
{
    public abstract class EntityMapping<TEntity, TKeyType> : ClassMap<TEntity>
        where TEntity : EntityBase<TKeyType>
    {
        protected EntityMapping()
        {
            Not.LazyLoad();

            if (default(TKeyType) is int)
            {
                Id(x => x.Id).GeneratedBy.Identity();
            }
            else if (default(TKeyType) is Guid)
            {
                Id(x => x.Id).GeneratedBy.GuidComb();
            }

            Component(x => x.Timestamp);
        }
    }
}